﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="toimiku_dokumentRequest", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(ToimikuDokumentRequest))]
    public class ToimikuDokumentRequestSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IToimikuDokumentRequest clazz;
        
        public ToimikuDokumentRequestSerializer(IToimikuDokumentRequest clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.AriregisterKasutajanimi!=null) {
                Writer.WriteStartElement("ariregister_kasutajanimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AriregisterKasutajanimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AriregisterParool!=null) {
                Writer.WriteStartElement("ariregister_parool");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AriregisterParool))).ToString());
                Writer.WriteEndElement();
            }
            Writer.WriteStartElement("dokumendi_id");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.DokumendiId))).ToString());
            Writer.WriteEndElement();
            if (clazz.DokumendiLiik!=null) {
                Writer.WriteStartElement("dokumendi_liik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokumendiLiik))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="ariregister_kasutajanimi") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AriregisterKasutajanimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ariregister_kasutajanimi")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="ariregister_parool") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AriregisterParool = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ariregister_parool")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="dokumendi_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>toimiku_dokumentRequest>dokumendi_id");
                }
                clazz.DokumendiId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("dokumendi_id")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>toimiku_dokumentRequest>dokumendi_id", Reader.LocalName);
            }
            if (Reader.LocalName=="dokumendi_liik") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.DokumendiLiik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("dokumendi_liik")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
        }
    }
}
